<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

     
class sfTdConditional extends sfTdBase {
    
    private $template;
    private $templateVars;
   
    
    public function setTemplate($template,$templateVars = array()) {
        $this->templateVars = $templateVars;
        $this->template = $template;
    }

    public function getTemplate() {
        return $this->template;
    }

    public function isModelTd() {
        return false;
    }
    
    
    public function render(&$dataSource) {
        $result = '<td style = "'.$this->style.'" class = "'.$this->htmlClass.'" >';
        
        $trans = array();
        foreach($this->templateVars as $templateVar)
        {        
            //if($this->parent->)
            $aux = explode('.', (string)$this->parent[$templateVar]->getField());
            $value = $this->getElem($dataSource, $aux);
            $trans['%'.$templateVar.'%'] = $value;
        }
        
        $result .= strtr($this->template, $trans);

        $result .= '</td>';
        return $result;
    }
    
}


?>
